<?php declare(strict_types=1);


namespace Database\Migration;


use Swoft\Db\Schema\Blueprint;
use Swoft\Devtool\Annotation\Mapping\Migration;
use Swoft\Devtool\Migration\Migration as BaseMigration;

/**
 * Class AddLoginTimesInTable
 *
 * @since 2.0
 *
 * @Migration(time=20201201102254)
 */
class AddLoginTimesInTable extends BaseMigration
{
    /**
     * @return void
     * @throws \ReflectionException
     * @throws \Swoft\Bean\Exception\ContainerException
     * @throws \Swoft\Db\Exception\DbException
     */
    public function up(): void
    {
        //添加字段
        $this->schema->table('user_consigner', function (Blueprint $blueprint){
            $blueprint->string('pay_password', 32)->default('')->after('password')->comment('支付密码： 默认为123456');
            $blueprint->integer('login_times')->default(0)->after('last_login_time')->comment('登陆次数： 初始为0');
        });

        $this->schema->table('user_carrier', function (Blueprint $blueprint){
            $blueprint->string('pay_password', 32)->default('')->after('password')->comment('支付密码： 默认为123456');
            $blueprint->integer('login_times')->default(0)->after('last_login_time')->comment('登陆次数： 初始为0');
        });
    }

    /**
     * @return void
     */
    public function down(): void
    {
        //省略回退操作
    }
}
